from redis import StrictRedis
import logging


class Config(object):

    # 链接数据库
    SQLALCHEMY_DATABASE_URI="mysql://root:mysql@127.0.0.1:3306/information_view"
    # 关闭数据库修改追踪
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SECRET_KEY = "iECgbYWReMNxkRprrzMo5KAQYnb2UeZ3bwvReTSt+VSESW0OB8zbglT+6rEcDW9X"
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379
    SESSION_TYPE = 'redis'
    # 初始化redis对象，
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    SESSION_USE_SIGNER = True
    SESSION_PERMANENT = False
    SESSION_KEY_PREFIX = 'information:'
    # 设置许可证有效时间.即设置存储在redis中数据的有效时间
    PERMANENT_SESSION_LIFETIME = 86400*2
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    DEBUG = False
    LOG_LEVEL = logging.WARNING


class DevelopmentConfig(Config):
    DEBUG = True


class TestingConfig(Config):
    DEBUG = True
    TESTING = True


config = {
    'production':ProductionConfig,
    'testing':TestingConfig,
    'development':DevelopmentConfig
}